package com.example.easypoi.controller;

import org.jeecgframework.poi.excel.export.styler.AbstractExcelExportStyler;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;

public class UserExportStyler extends AbstractExcelExportStyler {

    public UserExportStyler(Workbook workbook) {
        super.createStyles(workbook);
    }

    @Override
    public CellStyle getTitleStyle(short color) {
        CellStyle style = workbook.createCellStyle();
        Font font = workbook.createFont();
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
        font.setFontHeightInPoints((short) 14);
        style.setFont(font);
        // POI 3.x 用 short 常量
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);

        // 边框
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        return style;
    }

    @Override
    public CellStyle getHeaderStyle(short color) {
        // 与标题样式一样即可
        return getTitleStyle(color);
    }

    @Override
    public CellStyle getStyles(boolean parity, org.jeecgframework.poi.excel.entity.params.ExcelExportEntity entity) {
        CellStyle style = workbook.createCellStyle();
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setAlignment(CellStyle.ALIGN_CENTER);
        return style;
    }
}